package com.mzj.saas.mservice.community.controller;

import com.mzj.saas.commons.ApiData;
import com.mzj.saas.commons.ResultBean;
import com.mzj.saas.mservice.community.service.AppCommunityHouseService;
import com.mzj.saas.mservice.community.vo.HouseSurrenderVO;
import com.mzj.saas.mservice.house.vo.HouseVO;
import com.mzj.saas.mservice.house.vo.OrgVO;
import com.mzj.saas.mservice.property.vo.SaveOrEditVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 物业房产
 */

@Controller
@RequestMapping("/communityHouse")
public class AppCommunityHouseController {

    @Autowired
    private AppCommunityHouseService appCommunityHouseService;

    /**
     * 查询物业房产列表
     */
    @GetMapping("/pageslist")
    @ResponseBody
    public ResultBean<ApiData<HouseVO>> pageslist(@RequestHeader String accessToken,
                                                  @RequestParam(defaultValue = "0") Integer pageNumber,
                                                  @RequestParam(defaultValue = "10") Integer pageSize,
                                                  HouseVO vo,@RequestParam(required = false) List<String> houseIdList) {
        return appCommunityHouseService.pageslist(accessToken, pageNumber, pageSize, vo,houseIdList);
    }

    /**
     * 所属物业列表【当前登录用户自己所在企业以及下级企业是物业的】
     */
    @GetMapping("/propertyList")
    @ResponseBody
    public ResultBean<List<OrgVO>> propertyList(@RequestHeader String accessToken) {
        return appCommunityHouseService.propertyList(accessToken);
    }


    /**
     * 新增退租管理
     */
    @PostMapping("/addLeaseWithdrawal")
    @ResponseBody
    public ResultBean<Object> addLeaseWithdrawal(@RequestHeader String accessToken,@RequestBody HouseSurrenderVO vo){
        return appCommunityHouseService.addLeaseWithdrawal(accessToken,vo);
    }

    /**
     * 添加房屋管理员
     * @param accessToken
     * @param saveOrEditVO
     * @return
     */
    @PostMapping("/addHouseManager")
    @ResponseBody
    public ResultBean<Object> addHouseManager(@RequestHeader String accessToken,@RequestBody SaveOrEditVO saveOrEditVO ){
        return appCommunityHouseService.addHouseManager(accessToken,saveOrEditVO);
    }
}
